package cn.wei.sdd.core.controller.wx;


import cn.wei.common.result.R;
import cn.wei.sdd.base.util.JwtUtils;
import cn.wei.sdd.core.pojo.vo.UserAccountVO;
import cn.wei.sdd.core.service.UserAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户账户 前端控制器
 * </p>
 *
 * @author Wei
 * @since 2021-09-22
 */
@RestController
@Api(tags = "用户账户管理")
@RequestMapping("/wxApi/core/userAccount")
public class UserAccountController {

    @Resource
    private UserAccountService userAccountService;

    @ApiOperation("获取我的账户信息")
    @GetMapping("getMyAccount")
    public R getMyAccount(HttpServletRequest request){
        String token = request.getHeader("token");
        Long userId = JwtUtils.getUserId(token);
        Long userType = Long.valueOf(JwtUtils.getUserType(token));
        UserAccountVO userAccountVO = userAccountService.getMyAccount(userId,userType);
        return R.ok().data("userAccount",userAccountVO);

    }

}

